package com.zx.controller;/*
 *@program:SSM
 *@author: zhangjian
 *@Time: 2021/7/27  9:11
 */

import com.zx.entity.Contract;
import com.zx.entity.Project;
import com.zx.service.ContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.InitBinder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Controller
public class ContractController {

    @Autowired
    private ContractService contractService;

    /**
     * 添加合同信息
     */
    @RequestMapping("/addcontract")
    public String addContract(Contract contract){
        contractService.addContract(contract);
        return "redirect:index.jsp";
    }

    @InitBinder
    public void initData(WebDataBinder wdb){
        wdb.registerCustomEditor(Date.class, new CustomDateEditor(new SimpleDateFormat("yyyy-MM-dd"), true));
    }


    /**
     * 查询评审信息
     */
    @ResponseBody
    @RequestMapping("/findAllContract")
    public List findAllContract(){
        List<Contract> list = contractService.findAllContract();
        return list;
    }

}
